package org.hy.pay.message.web.base.controller.controller;


import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.hy.pay.common.core.page.PageBean;
import org.hy.pay.common.core.page.PageParam;
import org.hy.pay.common.core.validate.ValidatorUtils;
import org.hy.pay.message.api.RpTransactionMessageService;
import org.hy.pay.message.entity.RpTransactionMessage;
import org.hy.pay.message.model.AjaxJson;
import org.hy.pay.message.util.CommonConstant;
import org.hy.pay.message.util.ConfigData;
import org.hy.pay.message.web.base.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = "/message")
public class MessageController extends BaseController {

	@Autowired
	RpTransactionMessageService rpTransactionMessageService;


	@RequestMapping("/list")
	@ResponseBody
	public AjaxJson list(HttpServletRequest req,Integer current,Integer pageSize){
		PageParam pageParam = new PageParam(current,pageSize);
		PageBean page = rpTransactionMessageService.listPage(pageParam, null);
		return AjaxJson.ok(ConfigData.process(page, "message", CommonConstant.DEFAULT_CURRENT_VERSION));
		
	}
	
	@RequestMapping(value = "/save",method=RequestMethod.POST,produces="application/json;charset=UTF-8")
	@ResponseBody
	public AjaxJson save(@RequestBody RpTransactionMessage rpTransactionMessage){
		//校验数据
		ValidatorUtils.validateEntity(rpTransactionMessage);
		rpTransactionMessageService.saveMessageWaitingConfirm(rpTransactionMessage);
		return AjaxJson.ok();
	}

}
